//
// Created by 孟令涛 on 24-7-15.
//
#include "NeonEffectTask.h"
#include <math.h>
#include "tim.h"
#include "GlobalVars.h"

#define PI 3.14159265

void NeonEffectTask(void *argument) {
//    float t = 0;
    for (;;) {
//        uint16_t r = (uint16_t)(499.5 * (sin(t) + 1));
//        uint16_t g = (uint16_t)(499.5 * (sin(t + 2 * PI / 3) + 1));
//        uint16_t b = (uint16_t)(499.5 * (sin(t + 4 * PI / 3) + 1));

        __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_4, r); // Red
        __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_3, g); // Green
        __HAL_TIM_SET_COMPARE(&htim3, TIM_CHANNEL_2, b); // Blue

//        t += 0.05;
//        if (t >= 2 * PI) t = 0;

        osDelay(50); // 20Hz update rate
    }
}
